package com.duing.service.impl;

import com.duing.dao.BookMapper;
import com.duing.entity.Book;
import com.duing.service.BookService;
import com.duing.vo.BookVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookMapper bookMapper;

    @Override
    public List<BookVo> selectByName(String keyword) {
        List<Book> books = bookMapper.selectByName(keyword);
        List<BookVo> bookVos = new ArrayList<>();
        for (Book book : books) {
            BookVo vo = new BookVo();
            BeanUtils.copyProperties(book, vo);
            bookVos.add(vo);
        }
        return bookVos;
    }

}
